#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n + 2);
    for (int i = 1; i <=n; ++i){
        cin >> v[i];
    }
    long long ans = 0;

    vector<long long> sum(n + 2,0);
    for(int i = 1;i<=n;i++){
        sum[i] = sum[i-1]+v[i];
    }

    for(int i = 1;i<=n;i++){
        ans += v[i] * (sum[n] - sum[i]);
    }
    cout << ans;
    return 0;
}
